#include<iostream>
#include<map>
#include<string>
using namespace std;
int main()
{
	int n,i;
	char ch;
	string s1,s2;
	cin>>n;
	map<string,string>namemap;
	map<string,string>::iterator iter;
	for(i=0;i<n;i++)
	{
		cin>>ch;
		cin>>s1>>s2;
		if(ch=='N')
		{
			if(namemap.find(s1)!=namemap.end())
			{
				cout<<"ERROR: Exist\n";
			}
			else
			{
				namemap[s1]=s2;
				cout<<"New: OK\n";
			}
		}
		else
		{
			iter=namemap.find(s1);
			if(iter!=namemap.end())
			{
				if(!s2.compare(iter->second))
				cout<<"Login: OK\n";
				else
				cout<<"ERROR: Wrong PW\n";
			}
			else
			cout<<"ERROR: Not Exist\n";
		}
	}
}
